import { UserManager, WebStorageStateStore } from 'oidc-client'
import { oidcConfig } from '@/config/oidc'

const config = {
  ...oidcConfig,
  userStore: new WebStorageStateStore({ store: window.localStorage })
}

const userManager = new UserManager(config)

export default {
  getUser() {
    return userManager.getUser()
  },
  login() {
    return userManager.signinRedirect()
  },
  logout() {
    return userManager.signoutRedirect()
  },
  async handleCallback() {
    const user = await userManager.signinRedirectCallback()
    return user
  }
} 